/*
 * Copyright (c) 2010-2011 Josef Hardi <josef.hardi@gmail.com>
 * Copyright (c) 2010 Piotr Zagawa <piotr.zagawa@gmail.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package id.duapuluhdua.dakidaki.layers;

import android.graphics.Canvas;
import android.graphics.Rect;

import id.duapuluhdua.dakidaki.common.CommonActivity;
import id.duapuluhdua.dakidaki.map.Screen;

/**
 *
 */
public class LayerStats extends Layer
{
  /** Fields */
  private long mLastFrameTime = 0; // time elapsed between frames

  /**
   * The constructor.
   *
   * @param parent
   * @param screen
   */
  public LayerStats(CommonActivity parent, Screen screen)
  {
    super(parent, screen);
  }

  @Override
  public void initData()
  {
    // Do nothing.
  }

  @Override
  public void surfaceSizeChanged(int width, int height, int screenOrientation)
  {
    // Do nothing.
  }

  @Override
  public void doDraw(Canvas canvas, Rect area)
  {
    final long duration = System.currentTimeMillis() - mLastFrameTime;
    mLastFrameTime = System.currentTimeMillis();

    final int lineH = 16;
    final int posX = 8;
    int posY = 120;

    canvas.drawText("Rectangle: " + area.width() + "x" + area.height(),
        posX, posY, mDefaultText);
    posY += lineH;

    canvas.drawText("Frame time: " + duration + ", framerate: " + (1000 / duration),
        posX, posY, mDefaultText);
    posY += lineH;

    canvas.drawText("Test time: " + testLastFrameTime + " ms", posX, posY,
        mDefaultText);
    posY += lineH;
  }

  @Override
  public void updateObjectsState()
  {
    // Do nothing.
  }
}
